<template>
  <div>
    <el-tooltip content="畅所欲言~" effect="dark" placement="bottom">
      <a class="btn_item" @click="openDialog">
        <span class="btn_icon">
        <img alt="" class="btn_img" src="../assets/icons/feedback.png">
        </span>
        <span class="btn_name">反馈</span>
      </a>
    </el-tooltip>
    <!--反馈表单-->
    <el-dialog id="dialog_fb" :modal="false" :visible.sync="feedbackVisible" title="反馈">
      <el-form ref="fb-form" :model="fb">
        <el-form-item :label-width="formLabelWidth" label="类别">
          <el-select id="selectType" v-model="fb.type" placeholder="请选择反馈类型">
            <el-option label="站点缺失" value="站点缺失"></el-option>
            <el-option label="站点错误" value="站点错误"></el-option>
            <el-option label="其他" value="其他"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label-width="formLabelWidth" label="详情">
          <el-input v-model="fb.details" :rows="2" placeholder="请输入详情，请尽量包含有用信息（如站点名字、大概位置）" type="textarea"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog()">取 消</el-button>
        <el-button type="primary" @click="submit()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as api from '../api/index'

export default {
  name: "Feedback",
  data() {
    return {
      feedbackVisible: false,
      formLabelWidth: '120px',
      fb: {
        type: "",
        details: ""
      }
    }
  },
  methods: {
    openDialog() {
      this.feedbackVisible = true;
    },
    submit() {
      this.feedbackVisible = false;
      api.newFeedback(this.fb.type, this.fb.details)
        .then(() => {
          this.$message("提交成功~")
        })
    },
    closeDialog() {
      this.feedbackVisible = false;
    }
  }
}
</script>
<style scoped>
#selectType {
  position: absolute;
  margin-left: 0;
  width: 50px;
}
</style>
